package com.dao;

import com.bean.GoodsBean;
import com.util.JDBCUtil;
import com.util.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class GoodsDao {

    GoodsBean goodsBean = new GoodsBean();
    //查询
    //这个接口到底有什么用？
    public List<GoodsBean> selRow() throws SQLException {
        String sql = "SELECT * FROM tz_prod";
        return JDBCUtil.selRow(sql, null, new RowMapper() {
            @Override
            public Object selRow(ResultSet resultSet) throws SQLException {
                Integer prodid =resultSet.getInt("prodid");
                String prodname =resultSet.getString("prodname");
                Double oriprice =resultSet.getDouble("oriprice");
                Double price =resultSet.getDouble("price");
                String pic =resultSet.getString("pic");
                Integer status =resultSet.getInt("status");
                Integer totalstocks =resultSet.getInt("totalstocks");

                GoodsBean goodsBean = new GoodsBean();
                goodsBean.setProdid(prodid);
                goodsBean.setProdname(prodname);
                goodsBean.setOriprice(oriprice);
                goodsBean.setPrice(price);
                goodsBean.setTotalstocks(totalstocks);
                goodsBean.setPic(pic);
                goodsBean.setStatus(status);
                return goodsBean;
            }
        });
    }

    //删除
//    public int delRow(Integer prodid) throws SQLException {
//        String sql = "DELETE FROM tz_prod WHERE prod_id = ?";
//        return JDBCUtil.upDataRow(sql, new Object[]{prodid});
//    }



}
